<Ui xmlns="http://www.blizzard.com/wow/ui/">
	<CheckButton name="CombuctorSideTabButtonTemplate" virtual="true" hidden="true">
		<Size x="32" y="32"/>
		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="$parentBorder" file="Interface\SpellBook\SpellBook-SkillLineTab">
					<Size x="64" y="64"/>
					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="-3" y="11"/>
						</Anchor>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>
		<Scripts>
			<OnEnter>
				GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
				GameTooltip:SetText(self.tooltip);
			</OnEnter>
			<OnLeave function="GameTooltip_Hide"/>
		</Scripts>
		<NormalTexture/>
		<HighlightTexture file="Interface\Buttons\ButtonHilight-Square" alphaMode="ADD"/>
		<CheckedTexture file="Interface\Buttons\CheckButtonHilight" alphaMode="ADD"/>
	</CheckButton>

	<Button name="CombuctorFrameTabButtonTemplate" inherits="CharacterFrameTabButtonTemplate" virtual="true">
		<Scripts>
			<OnLoad>
				self:SetFrameLevel(self:GetFrameLevel() + 4);
			</OnLoad>
		</Scripts>
	</Button>

	<Button name="CombuctorIconButtonTemplate" virtual="true">
		<Size x="64" y="64"/>

		<Anchors>
			<Anchor point="TOPLEFT">
				<Offset x="-8" y="8"/>
			</Anchor>
		</Anchors>

		<Scripts>
			<OnLoad>
				self:RegisterForClicks("anyUp")
				self.icon = self:GetParent().portrait
				self.icon:ClearAllPoints()
				self.icon:SetPoint("CENTER", self)
			</OnLoad>
			<OnEvent>
				if (self:IsShown() and arg1 == "player") then
					SetPortraitTexture(self.icon, arg1)
				end
			</OnEvent>
			<OnShow>
				SetPortraitTexture(self.icon, "player")
				self:RegisterEvent("UNIT_PORTRAIT_UPDATE")
			</OnShow>
			<OnHide>
				self:UnregisterEvent("UNIT_PORTRAIT_UPDATE")
			</OnHide>
			<OnMouseDown>
				self.icon:SetWidth(56)
				self.icon:SetHeight(56)
				self.icon:SetTexCoord(0.075, 0.925, 0.075, 0.925)
			</OnMouseDown>
			<OnMouseUp>
				self.icon:SetWidth(62)
				self.icon:SetHeight(62)
				self.icon:SetTexCoord(0, 1, 0, 1)
			</OnMouseUp>
			<OnClick>
				if Combuctor.TogglePlayerDropdown then
					Combuctor:TogglePlayerDropdown(self, self:GetParent(), 15, 10)
				end
			</OnClick>
			<OnEnter>
				if Combuctor.TogglePlayerDropdown then
					self:GetParent():OnPortraitEnter(self)
				end
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide()
			</OnLeave>
		</Scripts>

		<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight">
			<Size x="78" y="78"/>
			<Anchors>
				<Anchor point="CENTER"/>
			</Anchors>
		</HighlightTexture>
	</Button>

	<Button name="CombuctorBagToggleTemplate" virtual="true">
		<Size x="32" y="32"/>

		<Layers>
			<Layer level="BACKGROUND">
				<Texture name="$parentIcon" file="Interface\Buttons\Button-Backpack-Up">
					<Size x="20" y="20"/>

					<Anchors>
						<Anchor point="TOPLEFT">
							<Offset x="7" y="-6"/>
						</Anchor>
					</Anchors>
					<TexCoords left="0.075" right="0.925" top="0.075" bottom="0.925"/>
				</Texture>
			</Layer>

			<Layer level="OVERLAY">
				<Texture name="$parentBorder" file="Interface\Minimap\MiniMap-TrackingBorder">
					<Size x="54" y="54"/>

					<Anchors>
						<Anchor point="TOPLEFT"/>
					</Anchors>
				</Texture>
			</Layer>
		</Layers>

		<Scripts>
			<OnLoad>
				self:RegisterForClicks("anyUp")
				_G[self:GetName() .. "Border"]:SetDesaturated(true)
				_G[self:GetName() .. "Border"]:SetAlpha(0.6)
			</OnLoad>
			<OnClick>
				self:GetParent():OnBagToggleClick(self, button)
			</OnClick>
			<OnMouseDown>
				_G[self:GetName() .. "Icon"]:SetTexCoord(0,1,0,1)
			</OnMouseDown>
			<OnMouseUp>
				_G[self:GetName() .. "Icon"]:SetTexCoord(0.075,0.925,0.075,0.925)
			</OnMouseUp>
			<OnEnter>
				self:GetParent():OnBagToggleEnter(self)
			</OnEnter>
			<OnLeave>
				GameTooltip:Hide()
			</OnLeave>
		</Scripts>
		<HighlightTexture alphaMode="ADD" file="Interface\Minimap\UI-Minimap-ZoomButton-Highlight"/>
	</Button>

	<EditBox name="CombuctorSearchBoxTemplate" autoFocus="false" inherits="InputBoxTemplate" virtual="true">
		<Size x="0" y="20"/>

		<Anchors>
			<Anchor point="TOPLEFT">
				<Offset x="70" y="-32"/>
			</Anchor>
			<Anchor point="TOPRIGHT">
				<Offset x="-80" y="-32"/>
			</Anchor>
		</Anchors>

		<Scripts>
			<OnShow>
				if self:GetText() == '' then
					self:SetText(SEARCH)
				end
			</OnShow>
			<OnEnterPressed>
				self:ClearFocus()
			</OnEnterPressed>
			<OnTextChanged>
				if self:HasFocus() then
					local text = self:GetText()
					if text == '' then
						text = nil
					end
					self:GetParent():SetFilter('name', text and text:lower() or nil, true)
				end
			</OnTextChanged>
			<OnEditFocusLost>
				self:HighlightText(0, 0)
				if self:GetText() == '' then
					self:SetText(SEARCH)
				end
			</OnEditFocusLost>
			<OnEditFocusGained>
				self:HighlightText()
				if self:GetText() == SEARCH then
					self:SetText('')
				end
			</OnEditFocusGained>
		</Scripts>
	</EditBox>

	<Button name="CombuctorResetButtonTemplate" virtual="true">
		<Size x="39" y="39"/>

		<Scripts>
			<OnClick>
				local parent = self:GetParent()
				local searchBox = getglobal(parent:GetName() .. 'Search')
				if searchBox:HasFocus() then
					searchBox:SetText('')
				else
					searchBox:SetText(SEARCH)
					self:GetParent():SetFilter('name', nil, true)
				end
			</OnClick>
		</Scripts>

		<NormalTexture file="Interface\Buttons\CancelButton-Up"/>
		<PushedTexture file="Interface\Buttons\CancelButton-Down"/>
		<HighlightTexture file="Interface\Buttons\CancelButton-Highlight" alphaMode="ADD"/>
	</Button>

	<Button name="CombuctorDragFrameTemplate" topLevel="true" virtual="true" text="TEXT">
		<Size x="262" y="14"/>

		<Scripts>
			<OnLoad>
				self:RegisterForDrag('LeftButton')
				self:SetPoint('TOP', self:GetParent().TitleText)
			</OnLoad>
			<OnMouseDown>
        if self:GetParent().sets.position then
          self.isMoving = true
          self:GetParent():StartMoving()
        end
			</OnMouseDown>
			<OnMouseUp>
				if self.isMoving then
					self.isMoving = nil
					self:GetParent():StopMovingOrSizing()
					self:GetParent():SavePosition(self:GetParent():GetPoint())
				end
			</OnMouseUp>
		</Scripts>

		<NormalFont style="GameFontNormal"/>
		<HighlightFont style="GameFontHighlight"/>
	</Button>
</Ui>